/*
 *  $Id: MeltingIcile.cs 1063 2010-05-20 17:40:43Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System;

namespace Ragima.Cards001.Water.Lands {
    public class MeltingIcile: LandCard {
        public MeltingIcile(): base("001_w_l_melting_icile") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Water;
            Value = 100;
            AddManaCost(ElementType.Water, 2);
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add(new Affects.ManaIncome(ElementType.Water, 2));
            affects.Add<MeltingIcileAffect>();
        }

        private class MeltingIcileAffect: Affect {
            public override string Id {
                get { return AffectManager.GetCardId<MeltingIcile>(null); }
            }

            public override void SetAffect() {
                base.SetAffect();
                GlobalSummary.OnUseCard += DoCard;
                EnemySummary.OnUseCard += DoCard;
            }
            public override void ResetAffect() {
                base.ResetAffect();
                GlobalSummary.OnUseCard -= DoCard;
                EnemySummary.OnUseCard -= DoCard;
            }

            private static readonly Type[] ManaSpells = {typeof(Spells.Tsunami), typeof(Spells.Deluge), typeof(Spells.OceanSouls), typeof(Spells.WaterInsanity)};

            private void DoCard(Card card, TargetArgs args) {
                if (Array.IndexOf(ManaSpells, card.GetType()) != -1)
                    Owner.Owner.IncrementMana(ElementType.Water, 1);
            }
        }
    }
}
